/**
 * 加载Bing地图
 */
class ProviderBing {
  key:string; 
  viewer: any;
  constructor(viewer: any) {
    this.viewer = viewer;
    this.key = "ApLjX8PkZuzzC_KSjaIcd0VfQV12ChuuQi0wo313bjs5t5qiz4WO9hJWjRAOO6Mv";
  }
  setMapStyleByBingMapHandler() {
    // Cesium.BingMapsStyle.AERIAL : String 影像地图
    // Cesium.BingMapsStyle.AERIAL_WITH_LABELS : String 带路网的影像
    // Cesium.BingMapsStyle.COLLINS_BART : String Collins Bart imagery.
    // Cesium.BingMapsStyle.ORDNANCE_SURVEY : String Ordnance Survey imagery
    // Cesium.BingMapsStyle.ROAD : String 矢量路网图
    this.viewer.imageryLayers.addImageryProvider(
      new Cesium.BingMapsImageryProvider({
        url: 'https://dev.virtualearth.net',
        mapStyle: Cesium.BingMapsStyle.AERIAL,
        key:this.key, //由BingMap官网申请的密钥
      })
    )
  }
  setTerrainServiceHandler() {
    // 根据坐标等参数设置当前场景的视角
    this.viewer.scene.camera.setView({
      destination: new Cesium.Cartesian3(-1206939.1925299785, 5337998.241228442, 3286279.2424502545),
      orientation: {
        heading: 1.4059101895600987,
        pitch: -0.20917672793046682,
        roll: 2.708944180085382e-13,
      },
    })
    this.viewer.terrainProvider = new Cesium.CesiumTerrainProvider({
      url: 'http://www.supermapol.com/realspace/services/3D-dixingyingxiang/rest/realspace/datas/DatasetDEM',
      isSct: true, //地形服务源自SuperMap iServer发布时需设置isSct为true
    })
  }
  init() {
    this.setMapStyleByBingMapHandler();
    // this.setTerrainServiceHandler();
  }
}

export default ProviderBing;